```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring框架底层原理深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f9fafb;
            color: #1f2937;
            line-height: 1.6;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #111827;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .code-block {
            background-color: #1e293b;
            color: #f8fafc;
            border-radius: 0.5rem;
            padding: 1.5rem;
            font-family: 'Courier New', Courier, monospace;
            position: relative;
        }
        .code-copy {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            color: #94a3b8;
            cursor: pointer;
            transition: all 0.2s;
        }
        .code-copy:hover {
            color: #e2e8f0;
        }
        .concept-card {
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
        }
        .concept-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .highlight {
            background: linear-gradient(120deg, #f0abfc 0%, #c4b5fd 100%);
            background-repeat: no-repeat;
            background-size: 100% 40%;
            background-position: 0 88%;
        }
        .mermaid-tooltip {
            background-color: #ffffff;
            border: 1px solid #e5e7eb;
            border-radius: 0.375rem;
            padding: 0.5rem 1rem;
            font-size: 0.875rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .first-letter-big::first-letter {
            font-size: 3.5rem;
            line-height: 1;
            float: left;
            margin-right: 0.5rem;
            margin-top: 0.5rem;
            color: #4f46e5;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-4">Spring框架底层原理</h1>
                    <p class="text-xl md:text-2xl opacity-90 mb-8">解密IoC、DI与AOP的魔法世界</p>
                    <p class="text-lg opacity-90 mb-8 first-letter-big">Spring作为Java生态中最受欢迎的企业级框架，其核心原理建立在控制反转(IoC)、依赖注入(DI)和面向切面编程(AOP)三大支柱之上。本文将深入剖析这些关键概念的技术实现，带您领略Spring框架的设计哲学。</p>
                    <div class="flex space-x-4">
                        <div class="flex items-center">
                            <i class="fas fa-code-branch mr-2"></i>
                            <span>设计模式</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-cogs mr-2"></i>
                            <span>架构设计</span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-layer-group mr-2"></i>
                            <span>框架原理</span>
                        </div>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative w-full max-w-md">
                        <div class="absolute -top-6 -left-6 w-32 h-32 bg-purple-300 rounded-full opacity-20"></div>
                        <div class="absolute -bottom-6 -right-6 w-32 h-32 bg-indigo-300 rounded-full opacity-20"></div>
                        <div class="relative bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-2xl p-6 shadow-lg border border-white border-opacity-20">
                            <div class="mermaid">
                                graph TD
                                    A[Spring Core] --> B[IoC Container]
                                    A --> C[AOP Framework]
                                    B --> D[Bean Definition]
                                    B --> E[Dependency Injection]
                                    C --> F[Proxies]
                                    C --> G[Aspects]
                                    D --> H[XML/Annotations]
                                    E --> I[Constructor Injection]
                                    E --> J[Setter Injection]
                                    F --> K[JDK Proxy]
                                    F --> L[CGLIB Proxy]
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-5xl mx-auto px-6 py-12">
        <!-- Overview Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="h-1 bg-gradient-to-r from-purple-500 to-indigo-600 flex-grow"></div>
                <h2 class="text-3xl font-bold px-4">核心概念</h2>
                <div class="h-1 bg-gradient-to-r from-indigo-600 to-purple-500 flex-grow"></div>
            </div>
            
            <p class="text-xl text-gray-700 mb-10 leading-relaxed first-letter-big">Spring的底层原理基于<span class="highlight font-medium">依赖注入</span>和<span class="highlight font-medium">控制反转</span>，通过Bean容器管理对象的生命周期和依赖关系，利用<span class="highlight font-medium">AOP</span>实现横切关注点的分离，提供了灵活的组件管理和面向切面编程的功能，从而实现了模块化、松耦合的企业级应用开发。</p>
            
            <div class="grid md:grid-cols-3 gap-6">
                <div class="concept-card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-exchange-alt text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">控制反转(IoC)</h3>
                    </div>
                    <p class="text-gray-600">将对象创建和依赖管理的控制权从代码中转移到Spring容器中，实现松耦合和可测试性。</p>
                </div>
                
                <div class="concept-card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-plug text-blue-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">依赖注入(DI)</h3>
                    </div>
                    <p class="text-gray-600">通过构造函数、Setter方法或字段自动注入依赖对象，解耦组件间关系。</p>
                </div>
                
                <div class="concept-card bg-white rounded-xl p-6">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-cut text-green-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">面向切面(AOP)</h3>
                    </div>
                    <p class="text-gray-600">将横切关注点(如日志、事务)与核心业务逻辑分离，提高代码模块化和可维护性。</p>
                </div>
            </div>
        </section>

        <!-- IoC Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="h-1 bg-gradient-to-r from-purple-500 to-indigo-600 flex-grow"></div>
                <h2 class="text-3xl font-bold px-4">控制反转(IoC)原理</h2>
                <div class="h-1 bg-gradient-to-r from-indigo-600 to-purple-500 flex-grow"></div>
            </div>
            
            <div class="flex flex-col md:flex-row gap-8 mb-10">
                <div class="md:w-1/2">
                    <p class="text-lg text-gray-700 mb-6 first-letter-big">控制反转是Spring框架的核心思想之一，它通过将应用程序的控制权从代码中转移到Spring容器中，实现了松耦合和可测试性。控制反转使得应用程序的组件之间不再紧密耦合，而是通过配置来定义它们之间的关系，从而使得应用程序更加灵活、可扩展和易于维护。</p>
                    
                    <div class="mb-6">
                        <div class="flex items-start mb-4">
                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                                <span class="text-purple-600 font-bold">1</span>
                            </div>
                            <div>
                                <h4 class="font-bold text-lg mb-1">Bean容器</h4>
                                <p class="text-gray-600">Spring框架的核心是一个容器，负责管理应用程序中的对象(Bean)。这个容器负责创建、装配、配置和管理Bean，从而解除了对象之间的依赖关系。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start mb-4">
                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                                <span class="text-purple-600 font-bold">2</span>
                            </div>
                            <div>
                                <h4 class="font-bold text-lg mb-1">Bean定义</h4>
                                <p class="text-gray-600">在Spring中，每个Bean都有一个对应的Bean定义，描述了Bean的类型、依赖关系和配置属性等信息。这些Bean定义可以通过XML配置文件、Java配置类或者注解来进行定义。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start mb-4">
                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                                <span class="text-purple-600 font-bold">3</span>
                            </div>
                            <div>
                                <h4 class="font-bold text-lg mb-1">依赖注入(DI)</h4>
                                <p class="text-gray-600">Spring通过依赖注入来管理Bean之间的依赖关系。在DI中，对象不再负责创建或查找依赖的对象，而是通过外部提供依赖的方式(如构造函数注入、Setter注入或字段注入)来实现依赖关系的注入。</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="md:w-1/2">
                    <div class="bg-white rounded-xl p-6 shadow-md">
                        <div class="mermaid">
                            sequenceDiagram
                                participant Client
                                participant IoC Container
                                participant BeanA
                                participant BeanB
                                
                                Client->>IoC Container: 请求BeanA实例
                                IoC Container->>BeanA: 创建实例
                                BeanA-->>IoC Container: 返回实例
                                IoC Container->>BeanB: 创建依赖BeanB
                                BeanB-->>IoC Container: 返回实例
                                IoC Container->>BeanA: 注入BeanB
                                IoC Container-->>Client: 返回装配好的BeanA
                        </div>
                    </div>
                    
                    <div class="code-block mt-6">
                        <button class="code-copy" title="复制代码"><i class="far fa-copy"></i></button>
                        <pre><code>@Service // 控制反转
public class UserServiceImpl implements UserService {
}

@Repository // 控制反转
public class UserDaoImpl implements UserDao {
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- DI Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="h-1 bg-gradient-to-r from-blue-500 to-indigo-600 flex-grow"></div>
                <h2 class="text-3xl font-bold px-4">依赖注入(DI)实现</h2>
                <div class="h-1 bg-gradient-to-r from-indigo-600 to-blue-500 flex-grow"></div>
            </div>
            
            <div class="flex flex-col md:flex-row gap-8">
                <div class="md:w-1/2">
                    <div class="bg-white rounded-xl p-6 shadow-md">
                        <div class="mermaid">
                            classDiagram
                                class MessageProcessor {
                                    -messageService : MessageService
                                    +processMessage()
                                }
                                
                                class MessageService {
                                    +getMessage() String
                                }
                                
                                MessageProcessor --> MessageService : @Autowired
                        </div>
                    </div>
                    
                    <div class="code-block mt-6">
                        <button class="code-copy" title="复制代码"><i class="far fa-copy"></i></button>
                        <pre><code>@Component
public class MessageProcessor {
    @Autowired // 依赖注入
    private MessageService messageService;

    public void processMessage() {
        String message = messageService.getMessage();
        System.out.println("Processing message: " + message);
    }
}</code></pre>
                    </div>
                </div>
                
                <div class="md:w-1/2">
                    <p class="text-lg text-gray-700 mb-6 first-letter-big">依赖注入通过将对象之间的依赖关系从代码中解耦，实现了松耦合和可测试性。依赖注入使得应用程序的组件之间不再紧密耦合，而是通过配置来定义它们之间的关系，从而实现了松耦合和可测试性。</p>
                    
                    <div class="mb-6">
                        <div class="flex items-start mb-4">
                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                                <span class="text-blue-600 font-bold">1</span>
                            </div>
                            <div>
                                <h4 class="font-bold text-lg mb-1">Bean容器</h4>
                                <p class="text-gray-600">Spring框架中的核心是Bean容器，它负责管理应用程序中的对象(Bean)。Bean容器负责创建、配置、装配和管理Bean。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start mb-4">
                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                                <span class="text-blue-600 font-bold">2</span>
                            </div>
                            <div>
                                <h4 class="font-bold text-lg mb-1">Bean定义</h4>
                                <p class="text-gray-600">每个Bean都有一个对应的Bean定义，描述了Bean的类型、依赖关系和配置属性等信息。Bean定义可以通过XML配置文件、Java配置类或者注解来进行定义。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start mb-4">
                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                                <span class="text-blue-600 font-bold">3</span>
                            </div>
                            <div>
                                <h4 class="font-bold text-lg mb-1">依赖注入方式</h4>
                                <p class="text-gray-600">Spring提供了多种依赖注入方式，包括构造函数注入、Setter注入和字段注入。这些不同的注入方式可以根据具体的场景和需求进行选择。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- AOP Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="h-1 bg-gradient-to-r from-green-500 to-teal-600 flex-grow"></div>
                <h2 class="text-3xl font-bold px-4">面向切面编程(AOP)</h2>
                <div class="h-1 bg-gradient-to-r from-teal-600 to-green-500 flex-grow"></div>
            </div>
            
            <div class="flex flex-col md:flex-row gap-8">
                <div class="md:w-1/2">
                    <p class="text-lg text-gray-700 mb-6 first-letter-big">AOP通过将横切关注点(如日志、事务管理等)从核心业务逻辑中分离出来，提高了代码的模块化和可维护性。AOP使得横切关注点可以与核心业务逻辑分离开来，提高了代码的可重用性和可维护性。</p>
                    
                    <div class="grid grid-cols-2 gap-4 mb-6">
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-bold text-green-600 mb-2">切面(Aspect)</h4>
                            <p class="text-sm text-gray-600">横切关注点的抽象，由切点和通知组成</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-bold text-green-600 mb-2">连接点(Join Point)</h4>
                            <p class="text-sm text-gray-600">程序执行中可以插入切面的点</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-bold text-green-600 mb-2">通知(Advice)</h4>
                            <p class="text-sm text-gray-600">切面在连接点处执行的具体行为</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-bold text-green-600 mb-2">切点表达式</h4>
                            <p class="text-sm text-gray-600">描述在何处应用通知的语言</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm col-span-2">
                            <h4 class="font-bold text-green-600 mb-2">代理(Proxy)</h4>
                            <p class="text-sm text-gray-600">Spring在运行时创建代理对象织入切面逻辑</p>
                        </div>
                    </div>
                    
                    <div class="code-block">
                        <button class="code-copy" title="复制代码"><i class="far fa-copy"></i></button>
                        <pre><code>@Aspect
@Component
public class LoggingAspect {
    @After("execution(* com.example.HelloService.sayHello(..))")
    public void afterHelloMethod() {
        System.out.println("After advice: Method executed successfully.");
    }
}</code></pre>
                    </div>
                </div>
                
                <div class="md:w-1/2">
                    <div class="bg-white rounded-xl p-6 shadow-md mb-6">
                        <div class="mermaid">
                            flowchart TD
                                A[业务组件] --> B[核心业务逻辑]
                                C[切面] --> D[前置通知]
                                C --> E[后置通知]
                                C --> F[异常通知]
                                C --> G[环绕通知]
                                B -->|被拦截| D
                                B -->|被拦截| E
                                B -->|被拦截| F
                                B -->|被拦截| G
                        </div>
                    </div>
                    
                    <div class="bg-white rounded-xl p-6 shadow-sm border-l-4 border-green-500">
                        <h3 class="font-bold text-xl mb-4">AOP底层实现</h3>
                        <p class="text-gray-700 mb-4">AOP的底层实现通常基于动态代理技术。在Spring中，主要有两种动态代理方式：</p>
                        
                        <div class="mb-4">
                            <h4 class="font-bold text-green-600 mb-2">JDK动态代理</h4>
                            <p class="text-gray-600">基于接口的动态代理，利用java.lang.reflect.Proxy类生成代理对象。当目标对象实现了接口时使用。</p>
                        </div>
                        
                        <div class="mb-4">
                            <h4 class="font-bold text-green-600 mb-2">CGLIB动态代理</h4>
                            <p class="text-gray-600">基于类的动态代理，利用字节码生成库CGLIB生成子类代理。当目标对象没有实现接口时使用。</p>
                        </div>
                        
                        <div class="code-block mt-4">
                            <button class="code-copy" title="复制代码"><i class="far fa-copy"></i></button>
                            <pre><code>// 动态代理保存字节码文件
System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles","true");</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 初始化Mermaid图表
            mermaid.initialize({
                startOnLoad: true,
                theme: 'default',
                flowchart: {
                    useMaxWidth: true,
                    htmlLabels: true,
                    curve: 'basis'
                },
                sequenceDiagram: {
                    useMaxWidth: true,
                    mirrorActors: false
                },
                classDiagram: {
                    useMaxWidth: true
                }
            });
            
            // 代码复制功能
            document.querySelectorAll('.code-copy').forEach(button => {
                button.addEventListener('click', function() {
                    const codeBlock = this.parentElement;
                    const code = codeBlock.querySelector('code').innerText;
                    navigator.clipboard.writeText(code).then(() => {
                        const originalIcon = this.innerHTML;
                        this.innerHTML = '<i class="fas fa-check"></i>';
                        setTimeout(() => {
                            this.innerHTML = originalIcon;
                        }, 2000);
                    });
                });
            });
            
            // 平滑滚动
            document.querySelectorAll('a[href^="#"]').forEach(anchor => {
                anchor.addEventListener('click', function(e) {
                    e.preventDefault();
                    document.querySelector(this.getAttribute('href')).scrollIntoView({
                        behavior: 'smooth'
                    });
                });
            });
        });
    </script>
</body>
</html>
```